package com.g3.zoosite.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.g3.zoosite.mapper.DwThemeParkMapper;
import com.g3.zoosite.model.DwThemePark;
import com.g3.zoosite.service.IDwThemeParkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 主题乐园信息表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-09-28
 */
@Service
public class DwThemeParkServiceImpl extends ServiceImpl<DwThemeParkMapper, DwThemePark> implements IDwThemeParkService {

    @Autowired(required = false)
    DwThemeParkMapper dwThemeParkMapper;

    @Value("${image-server}")
    private String imageServer;

    //查询所有主题乐园业务逻辑层方法
    @Override
    public List<DwThemePark> findThemeParks() {
        List<DwThemePark> themeParks = dwThemeParkMapper.selectList(null);
        for (int i=0;i<themeParks.size();i++){
            DwThemePark dwThemePark = themeParks.get(i);
            //拼接图片服务器和图片路径
            dwThemePark.setImagePath(imageServer + dwThemePark.getImagePath());
        }
        return themeParks;
    }

    //通过ID查询乐园信息
    @Override
    public DwThemePark findThemePark(Integer id) {
        DwThemePark themePark = dwThemeParkMapper.selectById(id);
        //拼接图片服务器和图片路径
        themePark.setImagePath(imageServer + themePark.getImagePath());
        return themePark;
    }
}
